package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.github.pagehelper.PageInfo;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * 大攻略
 */
@JsonIgnoreProperties("handler")
@Setter
@Getter
public class Strategy {
    public static final int STATE_NORMAL = 0;//推荐
    public static final int STATE_SHUT = 1;//禁用

    private Long id; //id

    private Region place; //所属地区

    private String title; //标题

    private String subTitle;//副标题

    private String coverUrl;//封面

    private Integer state;//状态
    //收藏数量
    private Integer  count; //  收藏总数

    public String getStateDisplay(){
        if (state==null){
            return "";
        }else if (state == STATE_NORMAL){
            return "推荐";
        }else if (state==STATE_SHUT){
            return "禁用";
        }else {
            return "";
        }
    }
    //编辑框的回显
    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        if (place!=null) {
            map.put("placeId", place.getId());
            map.put("placeName", place.getName());
        }
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

}